What is perfect-scrollbar?
The perfect-scrollbar npm package is a lightweight and customizable scrollbar plugin. It allows you to create custom scrollbars that look and behave consistently across different browsers and devices. It is particularly useful for creating scrollable containers with a more polished and user-friendly appearance.
What are perfect-scrollbar's main functionalities?
Custom Scrollbars
This feature allows you to initialize a custom scrollbar on a specified container element. The code sample demonstrates how to import the perfect-scrollbar package, select a container element, and initialize the custom scrollbar on that container.
const Ps = require('perfect-scrollbar');
const container = document.querySelector('#container');
Ps.initialize(container);
Update Scrollbars
This feature allows you to update the scrollbar when the content of the container changes. The code sample shows how to call the `update` method on the container to refresh the scrollbar.
const Ps = require('perfect-scrollbar');
const container = document.querySelector('#container');
Ps.initialize(container);
// Update the scrollbar when content changes
Ps.update(container);
Destroy Scrollbars
This feature allows you to destroy the custom scrollbar when it is no longer needed. The code sample demonstrates how to call the `destroy` method on the container to remove the custom scrollbar.
const Ps = require('perfect-scrollbar');
const container = document.querySelector('#container');
Ps.initialize(container);
// Destroy the scrollbar when no longer needed
Ps.destroy(container);
Other packages similar to perfect-scrollbar
simplebar
SimpleBar is a similar package that provides custom scrollbars with minimal setup. It automatically detects the container and applies custom scrollbars without requiring explicit initialization. Compared to perfect-scrollbar, SimpleBar is easier to set up but offers less customization.
react-custom-scrollbars
React Custom Scrollbars is a package specifically designed for React applications. It provides highly customizable scrollbars with a React component-based approach. Compared to perfect-scrollbar, it is more suitable for React projects and offers more flexibility in terms of customization.
overlayscrollbars
OverlayScrollbars is a highly customizable scrollbar plugin that supports both JavaScript and jQuery. It offers a wide range of customization options and is known for its performance and smooth scrolling experience. Compared to perfect-scrollbar, OverlayScrollbars provides more advanced features and customization options.
perfect-scrollbar
Minimalistic but perfect custom scrollbar plugin
Why perfect-scrollbar?
perfect-scrollbar is minimalistic but perfect (for us, and maybe for most
developers) scrollbar plugin.
- No change on design layout
- No manipulation on DOM tree
- Use plain
scrollTop
and scrollLeft
- Scrollbar style is fully customizable
- Efficient update on layout change
We hope you will love it!
Live preview
Check out the Live Preview snippet. You can fork it right away for testing and experimenting purposes.
Related resources
Social Media
Get Free Material Design for Bootstrap 5
|
- Material Design 2.0 + latest Bootstrap 5 based on plain JavaScript. 700+ material UI components, super simple, 1 minute installation, free templates & much more
|
Free Tutorials
Huge collection of free and high-quality tutorials. Learn Bootstrap, Angular, React, Vue, WordPress and many more. Create your own websites and apps.
Check it out